<template>
    <div>
        <cus-modal
            ref="modal"
            title="修改就餐人数"
            :width="1200"
            :closable="false"
            @on-visible-change="onVisibleChange"
        >
            <div class="noticeBox">
                <div style="color:red;font-size:12px">注：若就餐人数为0该餐次将不进行原料采购</div>
                <div style="padding:8px 0">
                    <RadioGroup v-model="modalType">
                        <Radio label="单个设置"></Radio>
                        <Radio label="整列设置"></Radio>
                        <Radio label="整行设置"></Radio>
                    </RadioGroup>
                </div>
                <div class="content-top-table">
                    <div class="addtable" style="height:100%">
                        <div class="addtable-title">
                            <div class="addtable-title-title">餐食</div>
                            <div class="addtable-title-item" v-for="(item, index) in dateList" :key="index">{{ dateStrList[index].name }}({{ item }})</div>
                        </div>
                        <div class="addtable-body">
                            <div class="addtable-body-hang" v-for="(item,key, index) in newData" :key="index" :class="'hang' + index%3">
                                <div class="addtable-body-hang-title">{{ key | mealTimeName(mealTimeList) }}</div>
                                <div class="addtable-body-hang-content" v-for="(it,idx, num) in item.dayMeal" :key="num" style="padding:10px 0;text-align:center">
                                    <!-- <div>{{index}}{{ idx }}{{   num }}</div> -->
                                    <InputNumber :min="0" :precision="0" v-model="it.repastNumber" style="width:80%;text-align:center!important" @on-change="(value) => { changeFour(value, key, index, idx, num) }"></InputNumber>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div slot="footer">
                <slot name="footer">
                    <div class="modal-footer">
                        <cus-button size="small" class="mr_2" @onClick="onCancel">关闭</cus-button>
                    </div>
                </slot>
            </div>
        </cus-modal>
    </div>
</template>

<script>

export default {
    components: {},
    name: "changeNum",
    data() {
        return {
            mealTimeList: [
                { label: 'breakfast', name: '早餐', type: 0 },
                { label: 'betwwenMealOne', name: '早~午间餐', type: 3 },
                { label: 'lunch', name: '午餐', type: 1},
                { label: 'betwwenMealTwo', name: '午~晚间餐', type: 4},
                { label: 'supper', name: '晚餐', type: 2 },
                { label: 'midnightMealOne', name: '夜餐1', type: 5 },
                { label: 'midnightMealTwo', name: '夜餐2', type: 6 }
            ],
            originData: {}, // 原始数据
            newData: {},
            nums: ['one', 'two', 'three', 'four', 'five', 'six', 'seven'],
            keysObjArr: [],
            modalType: '单个设置'
        };
    },
    props: {
        dateStrList: {
            type: Array,
            default () {
                return []
            }
        },
        dateList: {
            type: Array,
            default () {
                return []
            }
        }
    },
    // 餐次名称过滤
    filters: {
        mealTimeName(value, mealTimeList) {
            let a = mealTimeList.filter(item => item.label == value);
            return a.length ? a[0].name : '';
        }
    },
    mounted() {
       
    },
    methods: {
        onVisibleChange(v) {
            if(!v) {
                this.$parent.changguiId = null;
            }
        },     
        show(data) {
            this.$refs["modal"].show = true;
            this.newData = this.$cu.deepClone(data);
            console.log('11111',this.newData)
        },
        //模态框取消
        onCancel() {
            this.keysObjArr = [];
            this.$refs["modal"].show = false;
            this.$emit('filterMeal')
        },
        onOk() {
            this.keysObjArr.forEach(item => {
                item.days.forEach(it => {
                    if(it.cover) {
                        this.originData[item.label].dayMeal[it.label].food = this.newData[item.label].dayMeal[it.label].food;
                    }
                })
            })
            let a = this.$cu.deepClone(this.originData)
            this.$emit('coverSuccess', a);
            this.onCancel();
        },
        changeFour(value, key, index, idx, num) {
            console.log(value, key, index, idx, num)
            if(this.modalType == '单个设置') {
                this.$set(this.newData[key].dayMeal[idx], 'repastNumber', value)
                this.$emit('changerepastNumber', this.newData)
            } else if(this.modalType == '整列设置') {
                for (const key2 in this.newData) {
                    this.$set(this.newData[key2].dayMeal[idx], 'repastNumber', value)
                    this.$emit('changerepastNumber', this.newData)
                }
            } else if(this.modalType == '整行设置') {
                for (const key2 in this.newData[key].dayMeal) {
                    this.$set(this.newData[key].dayMeal[key2], 'repastNumber', value)
                    this.$emit('changerepastNumber', this.newData)
                }
            }
        }
    },
};
</script>

<style scoped lang="less">
/deep/.ivu-checkbox-border {
    line-height: 0!important;
}
/deep/.ivu-modal-mask {
    z-index: 999999!important;
}
/deep/.ivu-modal-wrap {
    z-index: 999999!important;
}

.content {
    background: #FFFFFF;
    border-radius: 4px;
    border: 0px solid #B9B9B9;
    &-top {  
        &-title {
            height: 80px;
            border-bottom: 1px solid rgba(0,0,0,0.0600);
            padding: 0 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            &-left {
                display: flex;
                &-name {
                    display: flex;
                    align-items: center;
                }
                div {
                    line-height: 40px;
                    font-size: 16px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    span {
                        margin-right: 10px;
                    }
                }
            }
            &-right {
                line-height: 40px;
                font-size: 16px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                span {
                    margin-right: 10px;
                }
            }
        }
        &-table {
            overflow: hidden;
            overflow-y: auto;
            // background-color: pink;
            // padding: 24px;
        }
    }
    &-bottom {
        height: 72px;
        background: #FFFFFF;
        box-shadow: 0px 5px 12px 4px rgba(0,0,0,0.0900), 0px 1px 6px 0px rgba(0,0,0,0.1200), 0px 1px 2px -2px rgba(0,0,0,0.1600);
        border-radius: 4px;
        border: 0px solid #B9B9B9;
        &-right {
            display: flex;
            align-items: center;
        }
    }
}
.addtable {
    &-title {
        display: flex;
        border-left: 3px solid #33A5FE;
        border-top: 1px solid #CCCCCC;
        border-bottom: 1px solid #CCCCCC;
        &-title {
            width: 160px;
            height: 50px;
            background: #33A5FE;
            border-right: 1px solid #CCCCCC;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #FFFFFF;
        }
        &-item {
            flex: 1;
            height: 50px;
            background: #33A5FE;
            border-right: 1px solid #CCCCCC;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #FFFFFF;
        }
    }
    &-body {
        overflow: hidden;
        overflow-y: auto;
        
        &-hang {
            display: flex;
            min-height: 33.3333%;
            border-bottom: 1px solid #CCCCCC;
            &-title {
                background: #FFF;
                border-right: 1px solid #CCCCCC;
                width:160px;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
            }
            &-content {
                flex: 1;
                border-right: 1px solid #CCCCCC;
            }
        }
    }
}
.hang1 {
    border-left: 3px solid #33C383;
    background: rgba(51, 195, 131, 0.1);
}
.hang2 {
    border-left: 3px solid #FFC432;
    background: rgba(255, 234, 153, 0.1);
}
.hang0 {
    border-left: 3px solid #49AFFF;
    background: rgba(73, 175, 255, 0.1);
}
</style>
